<%-- 
    Document   : create
    Created on : 24-jun-2014, 3:46:58
    Author     : Ewoud
--%>

<%@page contentType="text/html" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
        <title>Create Item</title>
    </head>
    <body>
        <%-- start web service invocation --%>
        <%
        try {
            webservice.ItemWebService_Service service = new webservice.ItemWebService_Service();
            webservice.ItemWebService port = service.getItemWebServicePort();
             // TODO initialize WS operation arguments here
            java.lang.String name = request.getParameter("name");
            java.lang.String description = request.getParameter("description");
            float price = Float.parseFloat(request.getParameter("price"));
            String typeString = request.getParameter("type");
            if(typeString.equals("BREAD")){
                port.createBread(name, description, price);
            } else if(typeString.equals("PIE")){
                port.createPie(name, description, price);
            } else {
                out.println("Couldn't create item via SOAP. Unknown type");
            }
        } catch (Exception ex) {
            out.println("Couldn't create item via SOAP");
        }
        %>
        <%-- end web service invocation --%>
        
        <a href="main.jsp" >Back</a>
        
        <h3>Items</h3>
        <table border="1" ><tbody><tr><td style="padding: 8px;">
            <%-- start web service invocation --%>
            <pre><%
            try {
                webservice.ItemWebService_Service service = new webservice.ItemWebService_Service();
                webservice.ItemWebService port = service.getItemWebServicePort();
                // TODO process result here
                java.lang.String result = port.getItems();
                out.println(result);
            } catch (Exception ex) {
                out.println("Couldn't get items via SOAP");
                // TODO handle custom exceptions here
            }
            %></pre>
            <%-- end web service invocation --%>
        </td></tr></tbody></table>
    </body>
</html>
